package one.stand.util;

import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

/**
 * @author: QIK
 * @CreateDate: 2019/4/15 17:09
 */
public class DateUtil {
    private static Map<Integer ,String>  monthMap=new HashMap<Integer, String>(0){{
        put(1,"January");
        put(2,"February");
        put(3,"March");
        put(4,"April");
        put(5,"May");
        put(6,"June");
        put(7,"July");
        put(8,"August");
        put(9,"Sept");
        put(10,"October");
        put(11,"November");
        put(12,"December");
    }};

    /**
     * 当前日
     * @return
     */
    public static String currentDay(){
        Calendar cal = Calendar.getInstance();
        Integer day=cal.get(Calendar.DATE);
        if(day<10){
            return "0"+day;
        }
        return day+"";
    }

    /**
     * 当前月
     * @return
     */
    public static String currentMonth(){
        Calendar cal = Calendar.getInstance();
        Integer month=cal.get(Calendar.MONTH) + 1;
        return monthMap.get(month);
    }

    /**
     * 当前年
     * @return
     */
    public static String currentYear(){
        Calendar cal = Calendar.getInstance();
        return cal.get(Calendar.YEAR)+"";
    }

}
